/* Copyright (C)
 * 2017 - Xianlee.Wu  xianleewu@163.com
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#ifndef __LEWEI_H__
#define __LEWEI_H__

#define LEWEI_GATEWAY       "http://www.lewei50.com/api/v1/gateway/updatesensors/"
#define LEWEI_POST_DATA_MAX_LEN 128
#define LEWEI_POST_URL_MAX_LEN  128
#define LEWEI_USER_KEY_MAX_LEN  128
#define LEWEI_POST_DATA_FORMAT  "[\n{\n\"Name\":\"%s\",\n\"Value\":\"%d\"\n}\n]"

int lewei_global_init();

int lewei_global_deinit();

int lewei_format_data(char* buf, int len, const char* device_name, int value);

int lewei_do_post(int gateway_num, const char* userkey, const char* data, int len);

int lewei_update_value(int gateway_num, const char* userkey, const char* device_name, int value);

#endif
